package swingTest;

import cn.dragon.eatingfish.Images;

import java.awt.*;
import java.util.Enumeration;

import javax.swing.*;
import javax.swing.plaf.FontUIResource;

public class JFrameCloseDemo {

    public static void main(String[] args) {

        JFrame jFrame = new JFrame();
        JPanel jPanel = new JPanel() {
            @Override
            public void paint(Graphics g) {
                UIManager.put("swing.boldMetal", Boolean.FALSE);
                super.paint(g);
                g.setFont(new Font("微软雅黑", Font.BOLD, 24));
                g.drawString("当前可吃", 90, 50);
                Images.fish_2_L.paintIcon(null, g, 100, 100);
                g.setFont(new Font("微软雅黑", 0, 30));
                g.drawString("游戏规则", 5, 200);

            }
        };
        jFrame.add(jPanel);
        jFrame.setSize(300, 700);
        jFrame.setVisible(true);
        jFrame.setLocation(1500, 200);
        jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        jFrame.setTitle("游戏规则");
    }

    private static void initGlobalFont() {
        FontUIResource fontUIResource = new FontUIResource(new Font("宋体", Font.PLAIN, 12));
        for (Enumeration keys = UIManager.getDefaults().keys(); keys.hasMoreElements(); ) {
            Object key = keys.nextElement();
            Object value = UIManager.get(key);
            if (value instanceof FontUIResource) {
                UIManager.put(key, fontUIResource);
            }
        }
    }
}
